from ultralytics import YOLO
import multiprocessing


def main():
    local_weights = "yolov12mmode.pt"
    model = YOLO(local_weights)

    # 训练时直接指定 GPU、多 GPU、自适应学习率和早停
    results = model.train(
        data="my_dataset.yaml",
        imgsz=640,
        batch=16,
        device=0,
        save=True,
        lr0=1e-3,
        lrf=0.05,
        amp=False,
        cos_lr=True,
        patience=10)

if __name__ == "__main__":
    multiprocessing.freeze_support()
    main()
